//
//  ZYXBigPicViewController.m
//  OCUIBasis
//  大图展示
//

#import "ZYXBigPicViewController.h"

@interface ZYXBigPicViewController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;

@property (weak, nonatomic) IBOutlet UIImageView  *minionView;

- (IBAction)scrollBtnClick;

@end

@implementation ZYXBigPicViewController

// 如果UIScrollView无法滚动，可能是以下原因：

// 1 没有设置contentSize
// 2 scrollEnabled = NO
// 3 没有接收到触摸事件:userInteractionEnabled = NO
// 4 没有取消autolayout功能（要想scrollView滚动，必须取消autolayout）

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // 设置scrollView内容的尺寸(滚动的范围)
    self.scrollView.contentSize = CGSizeMake(892, 632);
    //self.scrollView.contentSize = self.minionView.image.size;
    //self.scrollView.contentSize = self.minionView.frame.size; // 总体内容的范围(滚动范围)
    
    
    //self.scrollView.scrollEnabled = NO;
    
    //self.scrollView.userInteractionEnabled = NO;
    
    //取消UIScrollView所在控制器View的 autoLayout 功能
    
    // self.scrollView.frame.size; // 可视范围
    
    // CGFloat top, CGFloat left, CGFloat bottom, CGFloat right
    self.scrollView.contentInset = UIEdgeInsetsMake(100, 40, 60, 80);
}


- (IBAction)scrollBtnClick {

    //CGPoint offset = CGPointMake(-100, -100);
    CGPoint offset = self.scrollView.contentOffset;
    offset.x += 100;
    offset.y += 100;
    [self.scrollView setContentOffset:offset animated:YES];
    //[self.scrollView setContentOffset:offset animated:NO];

    
    
//    [UIView animateWithDuration:1.0 animations:^{
//        self.scrollView.contentOffset = CGPointMake(-100, -200);
//    }];
}
@end
